package com.pwt.entity;

import io.swagger.v3.oas.annotations.media.Schema;
import com.pwt.entity.base.BaseEntity;
import javax.persistence.*;
import lombok.EqualsAndHashCode;
import lombok.Data;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;


/**
 * 菜单
 *
 * @author auto generated
 * @date 2021-08-30 11:15:30
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Entity
@Table(name = "[menu]")
@Schema(name = "菜单")
@DynamicInsert
@DynamicUpdate
public class Menu extends BaseEntity {

	/**
	 * 权限名称
	 * nullable : true
	 * default  : null
	 */
	@Schema(name = "name",description = "权限名称")
	@Column(name = "name", nullable = true, length = 255)
	private String name;

	/**
	 * 权限等级
	 * nullable : true
	 * default  : null
	 */
	@Schema(name = "level", description = "权限等级")
	@Column(name = "level", nullable = true)
	private Integer level;

	/**
	 * 路由
	 * nullable : true
	 * default  : null
	 */
	@Schema(name = "path",description = "路由")
	@Column(name = "path", nullable = true, length = 255)
	private String path;

	/**
	 * 上级ID
	 * nullable : true
	 * default  : null
	 */
	@Schema(name = "parentId",description = "上级ID")
	@Column(name = "parent_id", nullable = true, length = 32)
	private String parentId;

	/**
	 * 图标
	 * nullable : true
	 * default  : null
	 */
	@Schema(name = "icon",description = "图标")
	@Column(name = "icon", nullable = true)
	private String icon;

	/**
	 * 排序
	 * nullable : true
	 * default  : null
	 */
	@Schema(name = "sortNumber",description = "排序")
	@Column(name = "sort_number", nullable = true)
	private Integer sortNumber;

	/**
	 * 权限标识
	 * nullable : true
	 * default  : null
	 */
	@Schema(name = "permission",description = "权限标识")
	@Column(name = "permission", nullable = true, length = 255)
	private String permission;

	@Transient
	@Schema(hidden = true)
	private boolean checked;

	@Override
	public boolean equals(Object o) {
		if (this == o) {
			return true;
		}

		if (o == null || getClass() != o.getClass()) {
			return false;
		}

		Menu menu = (Menu) o;

		return menu.getId().equals(this.id);
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder(17, 37).appendSuper(super.hashCode()).append(name).append(level).append(path).append(parentId).append(sortNumber).append(permission).toHashCode();
	}
}
